classdef student
    properties
        name = ''
        number= ''
        major = ''
        class = [0, 0, 0, 0, 0]
    end
    methods
        function inst = student(nme, num, maj, cls1, cls2, cls3, cls4, cls5)
            inst.name = nme;
            inst.number = num;
            inst.major = maj;
            inst.class(1) = cls1;
            inst.class(2) = cls2;
            inst.class(3) = cls3;
            inst.class(4) = cls4;
            inst.class(5) = cls5;
        end
        function inst = addStudent(a,nme, num, maj, cls1, cls2, cls3, cls4, cls5)
            inst = [a;student(nme, num, maj, cls1, cls2, cls3, cls4, cls5)];
        end
        function inst = deleteStu(inst, i)
            inst(i,:) = [];
        end
        function inst = modifyStu(inst, nme, num, maj)
            inst.name = nme;
            inst.number = num;
            inst.major = maj;
        end
        function inst = addScore(inst, n, arr)
            line_size = length(inst.class);
            for i = 1:n
                inst.class(i + line_size) = arr(i);
            end
        end
        function inst = delScore(inst, cls)
            inst.class(cls) = 0;
        end
        function inst = modifyScore(inst, cls, score)
            inst.class(cls) = score;
        end
        function av = avCalculate(inst, class_num)
            score_sum = 0;
            line = size(inst);
            for a = 1:line(1)
                score_sum = score_sum + inst(a).class(class_num);
            end
            av = score_sum/line(1);
        end
        function inst = myBubbleSort(inst, class_num)
            for i = 1:size(inst)
                for j = 1:size(inst) - i
                    if inst(j).class(class_num) > inst(j+1).class(class_num)
                        temp = inst(j);
                        inst(j) = inst(j+1);
                        inst(j+1) = temp;
                    end
                end
            end
        end
    end
end